The set of instructions which are executed by a processor are referred to as an instruction set and these instructions are typically mapped to instruction words as a way of presenting the hardware controls to the software. The processes of mapping instructions to instruction words and back may be referred to as encoding and decoding respectively. Code density may be used to compare different encoding schemes, where the code density is inversely proportional to the memory required to store all the encoded instructions (i.e. instruction words) used to perform a particular task (e.g. all the encoded instructions in a particular program). To increase the code density, short instruction words may be used and this may, for example, be achieved by limiting the functionality of the instruction set. Alternatively, variable length instruction words may be used, with shorter instruction words being used for more commonly used instructions and longer instruction words being used for less commonly used instructions.
The embodiments described below are provided by way of example only and are not limiting of implementations which solve any or all of the disadvantages of known methods of encoding and decoding instructions from an instruction set.